package com.dd.shop4j.common.utils.security;

import org.apache.shiro.SecurityUtils;
import com.dd.shop4j.common.utils.security.ShiroDbRealm.ShiroUser;

/**
 * Shiro用户Utils类
 * @author tangshu
 *
 */
public class ShiroUtils {

	/**
	 * 获取登录的当前用户
	 * @return
	 */
	public static ShiroUser getCurrentUser() {
		return (ShiroUser) SecurityUtils.getSubject().getPrincipal();
	}

	/**
	 * 获取当前用户的userid
	 * @return
	 */
	public static Integer getCurrentUserId() {
		ShiroUser user = getCurrentUser();
		if (user != null) {
			return user.getUserId();
		}
		return null;
	}
	
}